package com.changgou.goods.dao;

import com.changgou.goods.pojo.Brand;
import com.changgou.goods.pojo.Spec;
import feign.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface BrandMapper extends Mapper<Brand> {
    /**根据分类名称查询 品牌列表
     */
    @Select("SELECT name,image FROM tb_brand WHERE id  IN (SELECT brand_id FROM tb_category_brand WHERE  category_id IN (SELECT id FROM tb_category WHERE NAME=#{name}) )order by seq")
     List<Map> findListByCategoryName(@Param("name") String categoryName);

    /**根据商品名称查规格列表*/
    @Select("SELECT t3.`name`,t3.`options` FROM  tb_category t1  JOIN tb_template t2  ON t1.`template_id` = t2.`id` AND t1.`name` = #{name} JOIN tb_spec t3 ON t3.`template_id` = t2.`id` ORDER BY t3.`seq` ;")
    List<Map> findSpecByGoodName(@Param("name") String goodName);
}
